// turn a stitch and a grid into a bezier path

#import <Cocoa/Cocoa.h>

@class BWStitch;
@class BWGrid;

typedef struct BWPathelizer_StitchMetrics {
    BOOL bendy;
    
    float width;
    float length;

    NSPoint startCenter;
    NSPoint endCenter;

    float stitchAngle;
    
    NSPoint pt1, pt2, pt3, pt4; // corners of the rectanglular part

    float angle1, angle2, angle3, angle4;

    NSPoint controlPoint1;      // bezier path control points
    NSPoint controlPoint2;

    NSPoint controlPoint3;      // bezier path control points for second line
    NSPoint controlPoint4;

    NSPoint midpoint;

    NSAffineTransformStruct rawTransform;

} BWPathelizer_StitchMetrics;


@interface BWPathelizer : NSObject
{
}

+ (BWPathelizer *) defaultPathelizer;

+ (NSBezierPath *) makePathForStitch: (BWStitch *) stitch
                              inGrid: (BWGrid *) grid;

+ (NSBezierPath *) makeArrowPathForStitch: (BWStitch *) stitch
                                   inGrid: (BWGrid *) grid;

+ (BWPathelizer_StitchMetrics) calculateMetricsForStitch: (BWStitch *) stitch
                                                  inGrid: (BWGrid *) grid;
+ (BOOL) metricsAreDegenerate: (BWPathelizer_StitchMetrics) metrics;

@end // BWPathelizer

